package com.yc.springboot.favorite.anno;

import java.lang.reflect.Method;

@TestAnno(items = {"a","b","c"})
public class Demo {

    @TestAnno("hello")
    public void test(){

    }

    @TestAnno(name = "hello",value = "world")
    public void test2(){

    }

    public static void main(String[] args) {
        TestAnno annotation = Demo.class.getAnnotation(TestAnno.class);
        for (String item : annotation.items()) {
            System.out.println(item);
        }

        Demo demo = new Demo();
        Method[] methods = demo.getClass().getDeclaredMethods();
        for (Method method : methods) {
            TestAnno anno = method.getAnnotation(TestAnno.class);
            if (anno != null){
                System.out.println(anno.value());
            }
        }



        annotation = subDemo.class.getAnnotation(TestAnno.class);
        for (String item : annotation.items()) {
            System.out.println(item);
        }
        System.out.println(annotation.value());
        System.out.println(annotation.name());

    }
}

class subDemo extends Demo{

}
